// $codepro.audit.disable
package edu.gatech.oad.records;

import java.util.Date;

import edu.gatech.oad.doctorsorder.LabOrder;
import edu.gatech.oad.schedule.Appointment;
import edu.gatech.oad.ui.UserPanel;
import edu.gatech.oad.user.Patient;
import junit.framework.TestCase;

public class LabRemoveTester extends TestCase {

	private Patient curPatient;
	@SuppressWarnings("unused")
	private PatientHistoryPanel curPanel;
	private TreatmentRecord recordOne;
	private TreatmentRecord recordTwo;
	private LabResults labOne;
	private LabResults labTwo;
	private LabOrder labOrderOne;
	private LabOrder labOrderTwo;
	private PatientHistoryController curControl;
	
	public void setUpTest(){
		curPatient = new Patient("A");
		curPanel = new PatientHistoryPanel(curPatient.getPatientHistory(), curPatient, new UserPanel(curPatient));
		Appointment testAppoint = new Appointment(new Date(), null);
		recordOne = new TreatmentRecord(testAppoint);
		curPatient.getPatientHistory().addTreatmentRecord(recordOne);
		labOrderOne = new LabOrder("","","",77);
		labOne = new LabResults("", labOrderOne);
		curPatient.getPatientHistory().addLabRecord(labOne);
		labOrderOne.setLabResults(labOne);
		recordOne.addDoctorsOrder(labOrderOne);
		curControl = new PatientHistoryController(curPatient.getPatientHistory());
	}
	
	public void testRemoveOne(){
		setUpTest();
		curControl.removeLab(labOne);
		assertFalse(curPatient.getPatientHistory().getLabResults().contains(labOne));
		assertFalse(recordOne.getDoctorsOrders().contains(labOrderOne));
	}
	
	public void testRemoveTwo(){
		setUpTest();
		recordTwo = new TreatmentRecord(new Appointment(new Date(), null));
		labOrderTwo = new LabOrder("","","",7);
		labTwo = new LabResults("", labOrderTwo);
		curPatient.getPatientHistory().addLabRecord(labTwo);
		labOrderTwo.setLabResults(labTwo);
		recordTwo.addDoctorsOrder(labOrderTwo);
		curControl.removeLab(labOne);
		
		assertFalse(curPatient.getPatientHistory().getLabResults().contains(labOne));
		assertFalse(recordOne.getDoctorsOrders().contains(labOrderOne));
		assertTrue(curPatient.getPatientHistory().getLabResults().contains(labTwo));
		assertTrue(recordTwo.getDoctorsOrders().contains(labOrderTwo));
	}
}
